// Copyright 2011 Hunter Freyer
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package languish.base.testing;

import java.util.HashMap;

import languish.base.NativeFunction;
import languish.base.Primitive;
import languish.base.Reducer;
import languish.base.Term;
import languish.base.Terms;

public class TestUtil {

  public static final Reducer BASIC_REDUCER =
    new Reducer(new HashMap<Integer, NativeFunction>());

  public static final Primitive ZERO = singleBytePrimitive(0);
  public static final Primitive ONE = singleBytePrimitive(1);
  public static final Primitive TWO = singleBytePrimitive(2);
  public static final Primitive THREE = singleBytePrimitive(3);
  public static final Primitive FOUR = singleBytePrimitive(4);
  public static final Primitive FIVE = singleBytePrimitive(5);
  public static final Primitive SIX = singleBytePrimitive(6);
  public static final Primitive SEVEN = singleBytePrimitive(7);
  public static final Primitive EIGHT = singleBytePrimitive(8);
  public static final Primitive NINE = singleBytePrimitive(9);
  public static final Primitive TEN = singleBytePrimitive(10);
  public static final Primitive ELEVEN = singleBytePrimitive(11);
  public static final Primitive TWELVE = singleBytePrimitive(12);
  public static final Primitive THIRTEEN = singleBytePrimitive(13);
  public static final Primitive FOURTEEN = singleBytePrimitive(14);
  public static final Primitive FIFTEEN = singleBytePrimitive(15);

  public static final Term IDENT = Terms.abs(Terms.ref(1));
  public static final Term OMEGA =
    Terms.abs(Terms.app(Terms.ref(1), Terms.ref(1)));
  public static final Term LOOP = Terms.app(TestUtil.OMEGA, TestUtil.OMEGA);

  public static Primitive singleBytePrimitive(byte b) {
    byte[] bytes = { b };
    return new Primitive(bytes);
  }

  public static Primitive singleBytePrimitive(int b) {
    return singleBytePrimitive((byte) b);
  }
}
